package time_consume;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.math.BigDecimal;

public class BeanDemo implements Writable {
    //time
    private String time;
    //price
    private String price;

    public BeanDemo(){}

    public BeanDemo(String time, BigDecimal price) {
        this.time = time;
        this.price = String.valueOf(price);
    }

    @Override
    //序列化操作
    public void write(DataOutput out) throws IOException {
        out.writeUTF(time);
        out.writeUTF(price);
    }

    @Override
    //反序列化操作
    public void readFields(DataInput in) throws IOException {
        time = in.readUTF();
        price = in.readUTF();
    }

    public String getTime() {
        return time;
    }

//    public void setTime(String time) {
//        this.time = time;
//    }

    public BigDecimal getPrice() {
        return new BigDecimal(price);
    }

//    public void setPrice(BigDecimal price) {
//        this.price = String.valueOf(price);
//    }

    @Override
    public String toString() {
        return "\n" + time + "\n" + price;
    }
}
